package org.jasper.impl.project;

import org.jasper.api.base.KieBaseModel;
import org.jasper.api.project.KieProject;
import org.jasper.api.session.KieSessionModel;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by OP038074 on 2018/7/9.
 */
public abstract class AbstractKieProject implements KieProject {
    private KieSessionModel defaultStatelessKieSession = null;
    private KieSessionModel defaultKieSession = null;
    protected final Map<String, KieSessionModel> kSessionModels = new HashMap<String, KieSessionModel>();
    private KieBaseModel defaultKieBase = null;
    protected final Map<String, KieBaseModel> kBaseModels = new HashMap<String, KieBaseModel>();

    public KieSessionModel getDefaultStatelessKieSession() {
        return defaultStatelessKieSession;
    }

    public KieSessionModel getDefaultKieSession() {
        return defaultKieSession;
    }

    public KieSessionModel getKieSessionModel(String kSessionName) {
        return kSessionName == null ? getDefaultKieSession() : kSessionModels.get( kSessionName );
    }

    public KieBaseModel getKieBaseModel(String kBaseName) {
        return kBaseName == null ? getDefaultKieBaseModel() : kBaseModels.get( kBaseName );
    }

    public KieBaseModel getDefaultKieBaseModel() {
        return defaultKieBase;
    }
}
